Methods and systems for synchronizing data in a multi-tenant database environment

ABSTRACT

In accordance with embodiments, there are provided mechanisms and methods for synchronizing data in a database network system. These mechanisms and methods for synchronizing data in database network system can enable embodiments to provide users a synchronization button on a UI or synchronization field through an API for specifying data for synchronization. The ability of embodiments to provide users a synchronization button on a UI or synchronization field through an API for specifying data for synchronization can enable users to easily and efficiently change and update data in a database system.

CLAIM OF PRIORITY

This application is a continuation of U.S. patent application Ser. No.14/629,466, filed Feb. 23, 2015, which is a continuation of U.S. patentapplication Ser. No. 14/034,796, filed Sep. 24, 2013, now U.S. Pat. No.8,965,846 issued Feb. 24, 2015, which is a continuation of U.S. patentapplication Ser. No. 13/118,539, filed May 30, 2011, now U.S. Pat. No.8,572,029, issued Oct. 29, 2013, which claims the benefit of U.S.Provisional Patent Application No. 61/349,991, filed May 31, 2010. Thecontents of all applications listed above are incorporated herein, byreference, in their entirety.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

FIELD OF THE INVENTION

One or more implementations relate generally to synchronizing data in adatabase network system.

BACKGROUND

The subject matter discussed in the background section should not beassumed to be prior art merely as a result of its mention in thebackground section. Similarly, a problem mentioned in the backgroundsection or associated with the subject matter of the background sectionshould not be assumed to have been previously recognized in the priorart. The subject matter in the background section merely representsdifferent approaches, which in and of themselves may also be inventions.

In conventional sales environments, sales personnel use a variety oftechniques to keep track of customer and/or business information. Oneway sales personnel organize and keep track of customer and/or businessinformation is to store the information on an electronic database. Thestored customer and/or business information may include, for example,general customer and/or company information, customer contactinformation, potential business opportunity information, informationregarding quoted product pricing, a list of pricing of various productsoffered to the customer, etc. Some of the stored customer and/orbusiness information may be duplicated in different portions of anelectronic database.

Unfortunately, synchronizing specific portions of business informationassociated with a customer and/or business may conflict with existingdatabase logic. Triggers and other database logic may result in infiniteloop issues when synchronizing portions of business information on adatabase.

Accordingly, it may be desirable to provide techniques enabling datasynchronization in the database system to improve user efficiency of thedatabase system.

BRIEF SUMMARY

In accordance with embodiments, there are provided mechanisms andmethods for synchronizing data in a database network system. Thesemechanisms and methods for synchronizing data in database network systemcan enable embodiments to provide users a synchronization function, suchas by providing a button on a User Interface (UI) or may provide asynchronization field through an Application Program Interface (API) forspecifying data for synchronization. The ability of embodiments toprovide users a synchronization function can enable users to easily andefficiently change and update data in a database system.

In an embodiment, users may synchronize quote information with parentopportunity information by selecting a start synchronization buttonthrough a user interface (UI) or by setting a SyncedQuote field on theparent opportunity through an application programming interface (API).In an embodiment, during the synchronization of a quote with its parentopportunity, quote line items may be copied to the parent opportunity asopportunity line items. In an embodiment, the synchronization may beaccomplished by running a series of operations to delete, update, andinsert opportunity line items to match the line items of the quote.

In an embodiment, the price book of the opportunity may also besynchronized with the price book of the quote. In an embodiment,detection and prevention of infinite loops as a result of synchronizingquote information with parent opportunity information may be performedby employing a Boolean roll-backable variable. The Boolean roll-backablevariable indicates when an object is currently being synced. In anembodiment, if the Boolean roll-backable variable is set, a syncedobject cannot be synced again in the same transaction, resulting inthrowing an exception to avoid infinite loops, and doing an attemptedsynchronization.

While one or more implementations and techniques are described withreference to an embodiment in which techniques for synchronizing data ina database network system are implemented in a system having anapplication server providing a front end for an on-demand databaseservice capable of supporting multiple tenants, the present invention isnot limited to multi-tenant databases nor deployment on applicationservers. Embodiments may be practiced using other databasearchitectures, i.e., ORACLE®, DB2® by IBM® and the like withoutdeparting from the scope of the embodiments claimed.

Any of the above embodiments may be used alone or together with oneanother in any combination. Inventions encompassed within thisspecification may also include embodiments that are only partiallymentioned or alluded to or are not mentioned or alluded to at all inthis brief summary or in the abstract. Although various embodiments ofthe invention may have been motivated by various deficiencies with theprior art, which may be discussed or alluded to in one or more places inthe specification, the embodiments of the invention do not necessarilyaddress any of these deficiencies. In other words, different embodimentsof the invention may address different deficiencies that may bediscussed in the specification. Some embodiments may only partiallyaddress some deficiencies or just one deficiency that may be discussedin the specification, and some embodiments may not address any of thesedeficiencies.

BRIEF DESCRIPTION OF THE DRAWINGS

In the following drawings like reference numbers are used to refer tolike elements. Although the following figures depict various examples ofthe invention, the invention is not limited to the examples depicted inthe figures.

FIG. 1 illustrates a block diagram of an embodiment of an applicationplatform for providing data synchronization in a multi-tenant databaseenvironment;

FIG. 2 illustrates a flowchart of an embodiment of a system-side methodfor synchronizing data in a database network system;

FIG. 3 illustrates a flowchart of an embodiment of a method forsynchronizing related opportunity and quote data in a database networksystem;

FIG. 4 illustrates a flowchart of an embodiment of a method forperforming ongoing opportunity and quote data synchronization;

FIG. 5 illustrates a flowchart of an embodiment of a method forperforming initial opportunity and quote data synchronization;

FIG. 6 illustrates a flowchart of an embodiment of a method fordetecting infinite loop occurrences when synchronizing opportunity andquote data;

FIG. 7 illustrates a block diagram of an example of an environmentwherein an on-demand database service might be used;

FIG. 8 illustrates a block diagram of an embodiment of elements of FIG.7 and various possible interconnections between these elements;

FIG. 9 is a flowchart of an example of a method of using the environmentof FIGS. 7 and 8; and

FIG. 10 is a flowchart of an example of a method of making theenvironment of FIGS. 7 and 8.

DETAILED DESCRIPTION

Systems and methods are provided for synchronizing data in a databasenetwork system. As used herein, the term multi-tenant database systemrefers to those systems in which various elements of hardware andsoftware of the database system may be shared by one or more customers.For example, a given application server may simultaneously processrequests for a great number of customers, and a given database table maystore rows for a potentially much greater number of customers. As usedherein, the term query plan refers to a set of steps used to accessinformation in a database system.

Next, mechanisms and methods for providing data synchronization in adatabase network system will be described with reference to exampleembodiments.

Data Synchronization

Sales personnel need the ability to efficiently organize and trackcustomer and sales data. One method of organizing and tracking customerand sales data is entering and storing the data in an electronicdatabase. Sales personnel may enter and store a variety of customer datasuch as company name, contact numbers, prior sales history, etc. Salespersonnel may also need the ability to enter and store data related topotential customers and potential sales.

In this application, an opportunity refers to stored information, storedin a machine readable medium (e.g., a computer readable medium), about apotential customer, potential sale, or other potential businessarrangement that a company may store. For example, personnel, such assales personnel may be aware of opportunity information, which may beentered into the portion of a database that is reserved for the companyas a result of being a tenant in a multitenant database. An opportunitymay have many types of data associated with it. For example, anopportunity may have associated data representing a date of firstcontact by sales personnel or date that sales personnel first becameaware of the opportunity. An opportunity may also have associated dataabout what products and quantities of products might be sold and at whatprice. An opportunity may include a price book. A price book may be alist of all or some of the products offered by sales personnel to apotential customer and prices for the offered products. Differentpotential customers may be offered different price books. For example, alarge corporation may be offered a price book reflecting discountedpricing due to the potential for large orders requiring a greaterquantity of products. Alternatively, a small company may be offered aprice book reflecting higher pricing due to the smaller quantities ofproduct required. Even if all customers are offered the same prices, theprices may change with time, and as a consequence different quotes maybe associated with different price books, depending on when the quotewas offered.

A quote may be associated with an opportunity. A quote may include aprice and/or quantity stated to a potential customer that a salespersonmay reference at a later date. For example, from a given opportunity,sales personnel may contact a potential customer associated with theopportunity. The potential customer may request a quote for pricinginformation based on various desired quantities of a product. At a laterdate, the potential customer may contact sales personnel referencing thepreviously supplied pricing information to close a deal. The opportunityfrom which the quote originated from may be referred to as a parentopportunity of the quote. In an embodiment the opportunity is associatedwith a price book, and the quote is only associated with a price book asa result of the opportunity being associated with the price book.Optionally, a quote may also be associated with a price book, which maybe stored in association with the quote. For example, a webpage havingfields that display and/or for entering information about theopportunity and/or quote may have a link, which when activated causesthe price book to be displayed. The ability to rely on previously quotedinformation may facilitate the customer in making business decisions,and may save the sales person from embarrassing moments in which thesales person inadvertently quotes a different price than quoted in aprevious encounter.

With a large number of opportunities, quotes, and related data stored onan electronic database, keeping all the data organized and consistentcan become a challenge when changes are made to portions of dataaffecting other associated and/or related data. For example, salespersonnel may need to provide a revised quote to a potential customer orthe sales representative may give several different quotes to the samecustomer, which depend on which features the user desires. Once thecustomer selects an option and a final quote is accepted the opportunitymay need to be synchronized with the final quote. A revised quote maynecessitate editing the quote data and in an embodiment may in somecases also necessitate editing the price book data (e.g., by changingthe pricebook) and opportunity data associated with the quote. Keepingquote data and opportunity data in synchronization may be necessary inorder to provide consistent information. By providing a method forinitially synchronizing data as well as ongoing data synchronization inthe electronic database, editing and/or revising associated informationand/or data is simplified and kept accurate in an efficient manner.

FIG. 1 illustrates a block diagram of an embodiment of an applicationplatform 18 for providing data synchronization in a multi-tenantdatabase environment. Application platform 18 may include PL/SOQL 34,application setup mechanism 38, save routines 36, synchronizationalgorithm 100, QuoteSynchronizer 102, QuoteSynchronizerImpl 104,Synchronization Validator 106, LineItemSyncHelper 108,LineItemSyncHelperImpl 110, syncUtil 112, infinite loop detector 114,RollupSummary 116, Quote 118, IsSyncing 120, Quote Line Items 122,Quantity 124, Unit Price 126, Discount 128, Service Date 130,HasRevSchedule 132, HasQtySchedule 134, Other line items 136, and TotalQuote Price 138, and price book (of Quote) 140. Application platform 18may further include Opportunity 142, SyncedQuote 144, OppLineItems 146,Quantity 148, Unit Price 150, Discount 152, Service Date 154,HasRevSchedule 156, HasQtySchedule 158, Other line items 160, TotalOpportunity Price 162, and price book (of Opportunity) 164. In otherembodiments, application platform 18 may not have all of the elementslisted and/or may have other elements instead of, or in addition to,those listed.

Application platform 18 may be a framework that allows the execution ofapplications on a system, e.g., an operating system. PL/SOQL 34 mayprovide a programming language style interface extension for invocationsto developer applications. Application setup mechanism 38 may be used tosetup and support the creation and management of developer applications.Save routines 36 may be used to save developer applications created forapplication platform 18. Save routines 36 may include hooks that areactivated by a call to a save routine, where the hooks are forsynchronizing opportunities with quotes and/or for checking that theopportunities and quotes have been properly synchronized with oneanother. Application platform 18, PL/SOQL 34, save routines 36, andapplication setup mechanism 38 will be further described below inconjunction with a description of the environment where they may beused.

Synchronization algorithm 100 may be instructions for thesynchronization of data. It should be understood the word “instruction”may be used interchangeably herein with the words “code” and “function.”In an embodiment, synchronization algorithm 100 may be composed andorganized into subsets or classes of instructions for handling datasynchronization tasks. For example, synchronization algorithm 100 may beorganized into subsets of instructions, each subset of instructionsintended to perform specified tasks such as synchronizing data,validating synchronized data, detecting infinite loops, specifying datasets for synchronization, etc. QuoteSynchronizer 102 may be one or morefunctions used for synchronizing opportunity and quote data. In anembodiment, QuoteSynchronizer 102 may be used as part of an API or otherinterface for defining the methods used for performing synchronizationof quote and opportunity data. In an embodiment, QuoteSynchronizer 102may be used for performing both the initial synchronization of a quoteand opportunity data, as well as the ongoing synchronization of thequote and opportunity data.

QuoteSynchronizerImpl 104 may be the implementation of the quotesynchronization functions of QuoteSynchronizer 102 used for performingsynchronization of quote and opportunity data. In an embodiment, theQuoteSynchronizerImpl 104 class cannot be instantiated directly by theuser. In an embodiment, a public static get ( ) method may be called byQuoteSynchronizer 102, which returns a main implementation class of thequote or a disabled version of the main implementation class of thequote for the returned quotes that are disabled. In an embodiment, amain implementation class may be structured data associated with thequote. During a synchronization of an opportunity in response to recentchanges in a quote, line items in the opportunity are found thatcorrespond to line items in the quote that were changed, and each lineitem is updated. The updating may occur by creating a line item for theopportunity with the new information, deleting the original line item,and replacing the original line item with the newly created line item.Alternatively, the values in individual fields in the line item may bedeleted and replaced with the new values of the quote. SynchronizationValidator 106 may be one or more functions used to verify whether datasynchronization was executed properly. For example, in an embodiment,Synchronization Validator 106 may execute at the end of a transaction tovalidate whether synchronized opportunity data properly corresponds torelated quote data before allowing a commit to execute. If not all lineitems have been synchronized, the line items not yet synchronized, maythen be synchronized, prior to committing a change to the quote.

LineItemSyncHelper 108 may be one or more functions for synchronizingline items. In an embodiment, a line item may be data associated with aquote or opportunity. More specifically, a line item may be datarepresenting a product or service offered to a customer, stored as arecord in a database. In an embodiment, a line item may belong to anopportunity or a quote. A line item may have additional associated datasuch as the unit price of each product or service, quantity of eachproduct or service, the discount given, etc. LineItemSyncHelper 108 maybe used for ongoing synchronization of the individual line items of aquote with its parent opportunity. For example, if the unit price lineitem of a quote has a value of five dollars and is synchronized with itsparent opportunity unit price line item, if the quote unit price lineitem is revised to six dollars, the value of the opportunity unit priceline item is also revised to six dollars. LineItemSyncHelper 108functions for ongoing synchronization may also be used for synchronizingline items during initial synchronization. In an embodiment, to ensurethat every line item is synchronized, there may be a function (which mayhave a name such as LineItemSyncHelper.checkLineItemsAreSyncing) thatchecks that all of the line items (e.g., line item by line item) havebeen synchronized when a quote 118 and an opportunity 142 have beendesignated as requiring synchronization with one another. In anembodiment, the function that checks that each line item is synchronizedperforms a check that each line item is synchronized that is separatefrom the check that each line item is synchronized that is performed bysynchronization validator 106.

LineItemSyncHelperImpl 110 may be the implementation of the line itemsynchronization functions used for performing synchronization of quoteline item and opportunity line item data. In an embodiment, theLineItemSyncHelperImpl 110 class cannot be instantiated directly by theuser. In an embodiment, a public static get ( ) method may be called byLineItemSyncHelper 108 which returns a main implementation class or adisabled version if returned quotes are disabled.

SyncUtil 112 may include methods, functions, and logic being performedin different places consolidated into one convenient location. Forexample, SyncUtil 112 may contain static methods for common functionsand logic used for data synchronization. Infinite loop detector 114 maybe one or more functions for verifying triggers for performing datasynchronization do not point to each other resulting in repeatingsynchronization cycles. RollupSummary 116 may be one or more functionsused for calculating values from a set of related records summarizingthe content of those records (e.g., as a minimum value, maximum value,total, and/or average). For example, RollupSummary 116 may be used tocalculate the total sum pricing of all products that a customer may bepotentially interested in purchasing given as part of a quote.RollupSummary 116 may also be used to determine the highest and lowestvalue from a set of related records and/or count the number of records.

Quote 118 may be a database table that represents reference pricing andquantity information given by sales personnel to a customer. A “table”is one representation of a data object, and may be used herein tosimplify the conceptual description of objects and custom objects. Itshould be understood that “table” and “object” may be usedinterchangeably herein. Each table generally contains one or more datacategories logically arranged as columns or fields in a viewable schema.Each row or record of a table contains an instance of data for eachcategory defined by the fields. In an embodiment, quote 118 may berepresentative of a database table, the database table having multiplerecords, the fields of each record may be line items representing and/orassociated with various types of information given by sales personnel topotential customers. For example, each record may contain multiplecolumns of the database table and each column may represent differenttypes of quote data such as product types, product quantity, unit price,customer contact date, etc.

IsSyncing 120 may be a Boolean field of Quote 118. In an embodiment,IsSyncing 120 may be a flag indicating whether data is currently beingsynchronized or has been synchronized. In an embodiment, IsSyncing 120may contain a Boolean value of TRUE or FALSE. In order to “mark” a quoteas currently being synchronized, the IsSyncing Boolean field or flag maybe added to the quote object. In an embodiment, the IsSyncing 120Boolean field may be set to TRUE when a quote is initially synchronizedwith an opportunity. If the data is not currently being synchronized,then the IsSyncing 120 flag may be set to FALSE. In an embodiment, if itis desirable to synchronize a particular quote with an object (which mayhave the name Opportunity.SyncedQuote) a pointer pointing to the Quotemay be added. In an embodiment, when IsSyncing 120 is set to true (sothat IsSyncing=TRUE), a pointer is added to Opportunity.SyncedQuotepointing to the quote to indicate to synchronize the quote.

Optionally, IsSyncing 120 may be used to prevent infinite loops, bychecking whether IsSyncing 120 is set to TRUE prior to performingsynchronization. If upon checking, prior to performing asynchronization, it is determined that IsSyncing 120 is set to TRUE,then the synchronization is not performed, because a synchronization isalready in progress and allowing the synchronization to be performed maylead to an infinite loop. If upon checking, prior to performingsynchronization, that IsSyncing 120 is FALSE, then the synchronizationis performed, because no other synchronization is being performed andconsequently there is little danger of causing an infinite loop.Additionally, after determining that IsSyncing 120 is FALSE (as a resultof checking the value of IsSyncing 120 just prior to performingsynchronization), IsSyncing 120 is set to TRUE while the synchronizationis being performed.

Quote Line Items 122 may be objects representative of certaininformation given to a potential customer when providing a quote. QuoteLine Items 122 may represent products and/or services a customer isinterested in purchasing. In an embodiment, a Quote 118 may havemultiple Quote Line Items 122. In an embodiment Quote Line Items 122 maycontain data about products and/or services including quantity 124, unitprice 126, discount 128, and service date 130, and Quote Line Items 122may be associated with HasRevSchedule 132, and HasQtySchedule 134. Itshould be understood the use of the term “quote line item” may refer toQuote Line Items 122 and/or to the data contained in Quote Line Items122, such as Quantity 124, unit price 126, discount 128, and servicedate 130.

Quantity 124 may represent the number of units of a product or length ofservices that a customer is interested in purchasing. Unit price 126 mayrepresent the cost for a unit of a product, such as the cost of a pieceof a product or an hourly cost of a service that a customer isinterested in purchasing. Discount 128 may represent the markdown that acustomer can expect to receive from the list price for a product orservice. For example, a customer may receive a greater discount forordering a product in large quantities and/or at regular intervals.Service date 130 may represent the date a quote was provided to acustomer. HasRevSchedule 132 may be a variable that indicates whetherthe opportunity for the quote has a revenue schedule. The revenuerepresents the expected revenue from the sale of a product based on apredetermined delivery schedule. For example, the revenue schedule mayinclude the dollar amount expected from the monthly delivery of aparticular subscription service. In an embodiment, if the quote oropportunity has a revenue schedule, the system may prevent the updatingof the total price and quantity of the quote. HasQtySchedule 134 may bea variable that indicates whether a quantity schedule was created forthe quote. The quantity schedule represents the quantity of one or moreproducts a customer is scheduled to receive at regular intervals. Forexample, an individual may have a subscription service for monthly winedeliveries. The quantity schedule may represent the number of bottles acustomer would receive the first of each month. In an embodiment, theuser has the option of changing the quantity, and updating the unitprice to keep the total price the same or of keeping the unit price thesame and updating the total price to reflect the change in quantity.Other line items 136 may represent other data associated with quote lineitems 122 but which are not kept in synchronization with related parentopportunity line items.

Total price 138 may represent the sum of the cost of all products and/orservices related to the quote provided to a customer. Total price 138may be calculated using RollupSummary 116 to sum the cost of allproducts and/or services that are part of the quote. Price book 140contains the list of products and/or services and fees for a variety ofproducts and/or services offered by the tenant. A company may choose tokeep multiple price books to better organize their products andservices. Different divisions of a company may have price bookscontaining the same products and/or services but at different prices. Inan embodiment, a quote 118 can have a given quote line item 122 only ifthe quote 118 has a price book. In an embodiment, a given quote lineitem 122 must correspond to a product (or service) that is listed inprice book 140.

Opportunity 142 may be a database object that represents informationrelated to potential deals. Opportunity 142 may include potential dealinformation, such as total deal value, other competing suppliers, whatstage the deal is in, etc. Opportunity 142 may also include similarand/or related data as quote 118. For example, Opportunity 142 maycontain line items that represent data that is similar to theopportunity data, such as product and service types, product and servicequantity, discount, unit price, etc.

SyncedQuote 144 indicates which particular quote 118 an opportunity 142is being synchronized with. To allow performing initial synchronizationthrough an API, a lookup field called “SyncedQuote” may be added toOpportunity 142. In an embodiment, setting SyncedQuote 144 field to adifferent quote would synchronize an opportunity 142 with the quote 118indicated in the SyncedQuote 144 field. If the opportunity 142 wasalready synchronizing with another quote 118, the opportunity 142 wouldunsynchronize with the quote 118 first.

An opportunity 142 may have multiple quotes 118 associated with theopportunity 142. For example, from a given opportunity 142, multiplepackages may have been offered to a potential client, so that the clientmay assess, which package best suits their needs. A given item may bepriced differently in different packages/quotes. For example, in onequote the potential customer may be offered a volume discount for theitem that is not available in another quote based on purchasing a largernumber of that item than would be purchased in the other quote. In anembodiment, a particular organization may require opportunity 142 toreach a particular stage prior to sending a quote 118 to a customer. Inan embodiment, SyncedQuote 144 may allow a user to determine which quote118 an opportunity 142 is synchronized with.

Opportunity Line Items 146, which may also be referred to as opportunityline items, may be objects representative of certain data relating to anopportunity 142. Similar to Quote Line Items 122, Opportunity Line Items146 may represent products and/or services a customer is interested in.In an embodiment, an opportunity 142 may have multiple Opportunity LineItems 146. Opportunity Line Items 146 may be associated and/or relatedto data about products or services including quantity 148, unit price150, discount 152, and service date 154, which have similar descriptionsas quantity 124, unit price 126, discount 128, and service date 130,respectively, except that quantity 148, unit price 150, discount 152,and service date 154, relate to a opportunity line item and quantity124, unit price 126, discount 128, and service date 130 relate to aquote line item, which were described previously in conjunction withQuote Line Items 122, and therefore the description of quantity 148,unit price 150, discount 152, and service date 154 will not be repeatedhere. Similarly, HasRevSchedule 156, HasQtySchedule 158, total price 162and price book 164 have similar descriptions as HasRevSchedule 132,HasQtySchedule 134, total price 138 and price book 140, respectively,except that HasRevSchedule 156, HasQtySchedule 158, total price 162 andprice book 164 apply of a quote and HasRevSchedule 132, HasQtySchedule134, total price 138 and price book 140 apply to an opportunity, whichwere also previously described in conjunction with Quote 118, andtherefore the description of HasRevSchedule 156, HasQtySchedule 158,total price 162 and price book 164 will not be repeated here.

Sales personnel and/or users of the database system may initiallysynchronize a quote 118 with the quote's parent opportunity 142 eitherthrough the user interface (UI) by clicking a “Start Sync” button orthrough the application programming interface (API) by setting theSyncedQuote 144 field on the parent opportunity 142. During the initialsynchronization of a quote 118, quote line items 122 may be copied to anopportunity 142 as opportunity line items 146. The copying of the lineitems may be accomplished by running a series of operations to delete,update and insert opportunity line items 146 to match the line items onthe quote 118. In addition, optionally the price book 164 of theopportunity 142 may be changed to match the price book 140 of the quote118. For example, a given company may have a standard price book andanother price book with high volume discounts built-in. At the time theopportunity was created, the opportunity may have designated thestandard price book as price book 164. Then when a quote is offered, thehigh volume discount price book may have been designated as price book140. In an embodiment, if the synchronizing is activated, in response toprice book 164 being set to the high volume discount price book, pricebook 140 may be updated by changing price book 140 from the standardprice book to the high volume discount price book.

In an embodiment, Opportunity Line Items 146 and associated data may besynchronized with Quote Line items 122 and respective associated data.In an embodiment, changes made to Quote Line items 122 may result inchanges to Opportunity Line Items 146 by way of LineItemSyncHelper 108,which may be used for ongoing synchronization of the individual lineitems of a quote 118 with its parent opportunity 142.

In an embodiment, QuoteSynchronizer 102, QuoteSynchronizerImpl 104,LineItemSyncHelper 108, LineItemSyncHelperImpl 110, and SyncUtil 112 maybe the main synchronization classes. The main synchronization classesmay contain most of the logic for performing opportunity and quote datasynchronization. The code may be structured such that mostsynchronization logic is in a central place. The interfaces may also becreated such that the interfaces are easy to understand and easy todetermine what the interfaces accomplish.

Synchronization logic may also be placed in various save/delete/undeletehooks for Opportunity 142, Opportunity Line Items 146, Quote 118, QuoteLine Items 122 objects. The hooks may intercept or otherwise detectfunctions calls to save/delete/undelete functions associated withOpportunity 142, Opportunity Line Items 146, Quote 118, Quote Line Items122 objects and in response, activate synchronization logic prior to, inassociation with, and/or just after implementing a save/delete/undeleteassociated with associated Opportunity 142, Opportunity Line Items 146,Quote 118, and Quote Line Items 122 objects. The custom component allowsdevelopers to quickly reuse commonly used functions. For example, a savehook may be an often used function for saving data. In these locations,the synchronization logic may be mainly directed to calling the methodsimplemented in one or more of the main synchronization classes forperforming ongoing synchronization. The initial synchronization may bemore segmented as there are more steps and therefore more logic in theOpportunity save hook as well as in QuoteSynchronizer 102 (the initialsynchronization is discussed below in conjunction with FIG. 4).

Once a quote 118 is synchronized with the parent opportunity 142, in anembodiment, the system may keep the quote 118 and opportunity 142synchronized with each other, such that quote 118 is synchronized toopportunity 142 when opportunity 142 is altered and opportunity 142 issynchronized to quote 118 when quote 118 is altered. In an embodiment,when quote line items 122 or opportunity line items 146 are updated,fields on the corresponding opportunity or quote line items are kept insynchronization. In other embodiments, other items may also besynchronized. In an embodiment, when quote line items 122 or opportunityline items 146 are deleted, the corresponding opportunity or quote lineitems, respectively, may be automatically deleted. When quote oropportunity line items are inserted, equivalent line items may beinserted on the opportunity or quote, respectively.

The price book 140 of the quote and price book 164 of the opportunitymay also be kept in synchronization. In an embodiment, if theopportunity has line items, the price book is not synchronized, andconsequently in a further embodiment, the only time the price book issynchronized during ongoing synchronization is when neither theopportunity 142 nor the quote 118 has any line items. In an embodiment,after synchronization, prior to committing the resulting change, asynchronization validation is performed.

In an embodiment, ensuring all line items of a quote and opportunitypair that are marked as requiring synchronization, SyncValidator 106 mayfurther ensure that each of quote line items 122 and the opportunityline items are synchronized.

Once a quote 118 is synchronized with an opportunity 142, synchronizedquote lines may be linked with the corresponding opportunity lines thequote lines are synchronizing with. Opportunity line item 146 may beassociated with a foreign key that may be included in quote line item122 that may point the quote line item to the corresponding opportunityline item that needs to be synchronized. Similarly, a foreign key field“QuoteLineItem” may be included in an opportunity line item 146 thatpoints the opportunity line item 146 to a corresponding quote line item122 to which the opportunity line 146 item is being synchronized. Theforeign keys in quote line item 122 and opportunity line item 146 may beset during the initial synchronization with the opportunity. Inaddition, the foreign key in quote line item 122 associated with anopportunity line item may be set when quote 118 is created based onopportunity 146. In an embodiment, linking the quote line items 122 tocorresponding opportunity line items 146 when creating quote 118 enablessynchronization of the quote 118 without having to recreate all theopportunity line items.

FIG. 2 shows an embodiment of a system-side method 200 for synchronizingdata in a database network system. The system-side method 200 mayinclude insert row 202, delete row 204, update row 206, insert row 208,copy update 210, delete row 212, validate 214, and commit 216. In otherembodiments, system-side method 200 may not have all the steps listedand/or may have other steps instead of or in addition to those listed.

A system-side method 200 for synchronizing data in a database networksystem may begin with insert row 202. In step 202, in an embodiment, arow may be inserted into a first table for storing data if the data tobe stored or updated requires a new record because a record did notalready exist previously. In step 204, a row may be deleted from thefirst table if the data update deletes data and results in an extrarecord in the first table containing no data and/or if the update is anexpress deletion of a particular row that is no longer necessary orapplicable. In step 206, if data in a row needs to be changed, the rowis updated by changing, adding, and/or filling the row with datarepresenting the update. The update may be a change to default data in anewly created row to more useful data or may be a change in data in apreviously existing row. In step 208, a row may be inserted into asecond table (which is being synchronized to reflect the changes in thefirst table) that corresponds to a newly inserted row in the firsttable. Alternatively, if a record does not exist in the second tablethat corresponds to a record in the first table, the previouslycorresponding record may be added to the second table whether or not thecorresponding record of the first table was updated.

In step 210, updates to any rows of the first table are copied to thecorresponding rows of the second table. In step 212, if an extra row ispresent in the second table that does not exist in the first table(e.g., because that row was deleted from the first table), the extra rowis deleted from the second table to agree with the first table. In step214, the synchronization of the two tables may be validated. Forexample, validation may be performed by performing a comparison toverify the two tables contain the same number of rows and/or the rowscontain the same field values. Step 214 may be performed in response toactivating a save command, which in turn as a result of a hook activatesthe validation of the synchronization of step 214. If in step 214 it isdetermined that the two tables have not been properly synchronized, inan embodiment, the transaction is aborted. In an embodiment, the changesto the original record are stored and if the transaction does notcommit, the changes are undone and the records are restored to theiroriginal state. In an alternative embodiment, the original records arenot actually changed unless the transactions commits. Upon verification,in step 216, the tables are synchronized and a commit of the transactionin which the synchronization occurred is performed to apply the changesto the database.

FIG. 3 illustrates a flowchart of an embodiment of a method 300 forsynchronizing related opportunity and quote data in a database networksystem. The method 300 may include receive change 302, synchronizedparents 304, current synchronization 306, price book changed 308, quoteline items 310, synchronization price book 312, line items changed 314,and synchronization 316. In other embodiments, method 300 may not haveall of the elements listed and/or may have other elements instead of, orin addition to, those listed.

A method 300 for synchronizing related opportunity and quote data in adatabase network system may begin with receive change 302. In receivechange 302, a database network system may receive a request to make achange to opportunity or quote data from a user. In step 304, adetermination is made whether a parent opportunity and a related quote(to which the requested change is to be applied) are currently beingsynchronized. In an embodiment, the determination may be made byexamining whether a logical variable (which may be referred to as theSyncedQuote field) of the parent opportunity indicates that the parentopportunity is being synchronized. For example, if the SyncedQuote fielddoes not indicate that the parent items are to be synchronized, thenthere is no data to synchronize and the synchronization processterminates. If the SyncedQuote field indicates that the parentopportunity is being synchronized, then in step 306, a determination ismade whether a synchronization was performed in the present transaction.The determination may be made by checking whether the IsSynching flaghas been set. If the IsSynching flag has been set to TRUE, then asynchronization has already been performed during the presenttransaction, and therefore the synchronization process terminates toavoid an infinite loop. If the IsSynching flag has been set to FALSE,then in step 308 a determination is made whether the price book of theparent opportunity has changed. The determination may be made whiledetermining if there are other differences between the quote andopportunity by calling a method (which may be referred toSQuote.syncDiff PL/SQL) that returns the difference between quotes andopportunities. In an embodiment the method that checks for differencesbetween quotes and opportunities returns a list of quotes where theprice book is different from their opportunity parents, a list ofopportunity lines that point to existing quote lines, a list of quotelines that point to existing opportunity lines, a list of opportunitylines that do not point to existing quote lines, and a list of quotelines that do not point to existing opportunity lines. In an embodiment,opportunity line items that do not point to existing quote line itemsare deleted, which in some cases may remove all of the opportunity lineitems for the opportunity allowing the price book of the opportunity tobe changed. If the price book of the parent opportunity and the relatedquote has been changed, in step 310, a determination is made whether therelated quote has line items. If the quote has no line items, in step312, the quote price book is synchronized with the changed price book ofthe parent opportunity. Specifically, the price book of the quote ischanged to the price book of the parent opportunity. If the opportunityalready has line items, then the method moves from step 310 to step 314,and skips the synchronization of the price book. In step 314, the lineitems of the related quote are checked for differences with the parentopportunity line items. For example, in an embodiment, quantity, unitprice, discount, service date, HasQtySchedule, and/or HasRevScheduleline items of the quote are synchronized with their respectiveopportunity line item counterparts. Once the quote line items andopportunity line items are synchronized, the synchronization processterminates.

FIG. 4 illustrates a flowchart of an embodiment of a method 400 forperforming initial opportunity and quote data synchronization. Themethod 400 may include SyncedQuote changes 402, opportunityunsynchronization settings 404, which opps 406, set false IsSyncing 408,unset foreign keys 410, unset schedule flags 412, opportunitysynchronization settings 414, get quote 416, set true IsSyncing 418,call QuoteSynchronizer 420, call QuoteSyncDiff 422, synchronize quoteopportunity lines 424, delete opportunity lines 426, synchronize pricebooks 428, insert opportunity lines 430. In other embodiments, method400 may not have all of the steps listed and/or may have other elementsinstead of, or in addition to, those listed.

Initial Synchronization

Method 400 for initial synchronization of opportunity and quote data maybegin with SyncedQuote changes 402. In step 402, initial synchronizationmay be initiated by a function that is activated by a save hook that isassociated with an opportunity that is performed once before the rest ofthe workflow (which may be referred to asOpportunityFunctions.saveHook_BeforeWorkflowOnce), which may identifyopportunities by checking changed SyncedQuote fields and determiningwhere the SyncedQuote fields point. In step 404, settings ofopportunities that are not being synchronized according to steps 406-412that follow are performed. In step 406, a determination may be made todetermine which opportunities should be unsynchronized. In step 408, forthose opportunities that need to be unsynchronized, the logical variable(e.g, IsSyncing) that indicates whether the opportunity is being syncedis set to false (the IsSyncing field to FALSE) for quotes that are to beunsynchronized. In step 410, the foreign keys of quote line items thatpoint to the opportunity line items are unset. In step 412, the functiontriggered by a save hook (e.g.OpportunityFunctions.saveHook_BeforeWorkflowOnce) may unset scheduleflags on the quote lines.

In step 414, the settings of the opportunities determined to needsynchronization are set. In step 416, for the opportunities to besynchronized by a function triggered by a save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) may retrieve thequotes set by SyncedQuote field. In step 418, the IsSyncing field may beset to TRUE by a function triggered by a save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) for quotes that needto be synchronized.

In step 420, the function triggered by the save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) may then call afunction that synchronizes a quote (e.g., QuoteSynchronizer.sync( )) tothe corresponding opportunities. In step 422, the function thatsynchronizes the quote (e.g., QuoteSynchronizer.sync( )) may call themethod that returns the difference between the quote and the opportunity(SQuote.syncDiff pl/sql). The method that returns the difference betweenthe quote and the opportunity may return five lists. The lists mayinclude (1) quotes where the price book is different from the quote'sopportunity parents (2) opportunity lines that point to existing quotelines (3) quote lines that point to existing opportunity lines (4)opportunity lines that do not point to existing quote lines and (5)quote lines that do not point to existing opportunity lines. In step424, if there are quote lines that point to existing opportunity lines,the function that was triggered by the save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) may synchronize thequote lines that point to existing opportunity lines by calling anotherfunction that synchronizes individual lines of the quote (e.g.,LineItemHelper.syncExistingLineItemsInternal). In an embodiment, thefunction that synchronizes individual lines of the quote (e.g.,LineItemHelper.syncExistingLineItemsInternal) may get the correspondingopportunity lines and update them to match the quote lines.

In step 426, a function that synchronizes individual lines of the quote(e.g., OpportunityFunctions.saveHook_BeforeWorkflowOnce) may check ifthere are any opportunity lines to delete by determining if there areany opportunity lines that do not point to existing quote lines. In anembodiment, the function triggered by the save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) loads theseopportunity lines and deletes them.

In step 428, in an embodiment, after synchronizing quote lines thatpoint to existing opportunity lines and checking if there are anyopportunity lines to delete, the function triggered by the save hook(e.g., OpportunityFunctions.saveHook_BeforeWorkflowOnce) synchronizespricebooks if needed. The function triggered by the save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) determines if thereare any quotes where the price book is different from their opportunityparents and synchronizes the price books of the quotes and opportunitiesby calling a function for synchronizing the price book (e.g.,syncPricebookInternal). In an embodiment, calling the function forsynchronizing the price book (e.g., syncPricebookInternal) will get thecorresponding opportunities and update their price books to match thequote price books. In an embodiment, price books may not be changeduntil line items are deleted, because changing price books onsynchronized opportunities if there are line items is prohibited. In analternative embodiment, changing price books without changing line itemsis permitted and/or changing the price book on synchronizedopportunities when there are line items is permitted.

In step 430, in an embodiment, the function triggered by the save hook(e.g., OpportunityFunctions.saveHook_BeforeWorkflowOnce) checks if thereare any opportunity lines to insert by determining if there are anyquote lines that do not point to existing opportunity lines. In anembodiment, the function triggered by the save hook (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce) may load the quotelines that need to be inserted into the opportunity and may insert thecorresponding opportunity lines to match the quote lines that wereloaded.

In an embodiment, the logic supports bidirectional synchronization, fromquote to opportunity or opportunity to quote, and a function is includedfor specifying the direction of sysnchronization (e.g., SyncDirectionenum).

For the initial synchronization, the logic may be implemented in theOpportunity entity save lifecycle, because the synchronization isimplemented using the synchronization quote (e.g., SyncedQuote) lookupfield to synchronize the Opportunity, as described previously. In oneembodiment, the initial synchronization logic is located in the sameplace as ongoing synchronization for the Opportunity (e.g., inOpportunityFunctions.saveHook_PostSummariesOnce). In an embodiment, toavoid strange behavior such as items not rolling back properly (e.g., anerror may be thrown, even though not everything in the transaction hasbeen rolled back), the synchronization logic may be located in alocation that is associated with the hook that triggers thesynchronization before the work flow begins (e.g.,OpportunityFunctions.saveHook_BeforeWorkflowOnce). Executing a hookbefore the workflow begins may allow the initial synchronization logicto be executed in basically the same place that post triggers areexecuted. Executing the initial synchronization logic and post triggersin basically the same place may provide uniformity with the rest ofentity save logic, e.g. if the initial synchronization was implementedas a post trigger it should work the same way as when the initialsynchronization is not a post trigger. Executing a hook before theworkflow begins may also be consistent with keeping the initialsynchronization within the recursive save detection boundaries, whichmeans the workflow will execute once on the Opportunity and the rollupsfrom the Opportunity will also execute once. In an embodiment, anopportunity or quote can only be synchronized once during the saveprocess. Attempts to cause an additional synchronization to the sameobject (opportunity or quote) may result in the synchronization processfailing. Executing a hook before workflow begins works similarly toimplementing the initial synchronization as a post trigger and may bemore intuitive to a user.

Ongoing Synchronization

FIG. 5 illustrates a flowchart of an embodiment of a method 500 forperforming ongoing opportunity and quote data synchronization. Themethod 500 may include rollup 502, workflow 504, ongoing synchronization506, synchronization opportunity 508, synchronization quote 510,synchronization opportunity line items 512, synchronization delete quoteline items 514, synchronization quote line items 516, synchronizationdelete opportunity line items 518, and insert opportunity line items520. In other embodiments, method 500 may not have all of the stepslisted and/or may have other elements instead of, or in addition to,those listed.

A method 500 may begin with rollup 502. Rollup 502 may include executingfunctions and instructions necessary to perform calculations for rollupsummary fields. As explained previously, a rollup summary field (rsf)may contain the total sum pricing of all products that a customer may bepotentially interested in purchasing, given as part of quote.Alternatively, a rsf may contain the highest value from a set of relatedrecords, the lowest value from a set of related records, or a totalcount of the number of records.

In step 504, scheduled workflow tasks may be handled. For example, userspecified processes such as updating data fields, sending emailnotifications, or any workflow actions that are to be completed whencertain user specified conditions are met, may be handled in workflow504.

In an embodiment, it may be desirable for implementation of thesynchronization of opportunity and quote data produce a synchronizationalgorithm that performs well, is easy to understand and debug, handleserrors properly, maintains data integrity, and integrates well with theexisting entity save logic. A potential difficulty in synchronizingopportunity and quote data may be the initial synchronization andongoing synchronization can both trigger additional logic (throughtriggers, workflow, etc.) that could cause recursion, infinite looping,and unexpected behavior. In an embodiment, to avoid synchronizationdifficulties, the ongoing synchronization logic may be positioned aslate in the entity save lifecycle as possible, preferably after rollup502 and workflow 504. For example, if updating an opportunity line item,the triggers and rollup to opportunity may occur before synchronizingchanges to the quote line item. In an embodiment, the method 500 waitsfor quote line item saves to complete, which includes waiting for rollup502 to complete, before synchronizing the opportunity line item. Sincethe synchronization waits for the quote line items save to complete andfor rollup 502 to complete before synchronizing the opportunity lineitem, all of the ongoing synchronization logic and save hooks occurafter rollup 502 and workflow 504 have been completed.

In step 506, the logic for ongoing synchronization may be implemented.In an embodiment, the logic for ongoing synchronization may be locatedin routines that are triggered as a result of various save hooks in theobjects that support synchronization, which may be Opportunity,OppLineItem, Quote, and QuoteLineItem. Having the logic for ongoingsynchronization located in various save hooks in the objects thatsupport synchronization may enable a determination of when these objectsare updated, inserted, deleted (in an embodiment only line items aredeleted) and undeleted (in an embodiment only quote lines areundeleted). In an embodiment, each of the save hooks (or each of thesave hooks that trigger the synchronization) may occur after workflow504 and rollup 502 have been completed for the object.

In step 508, if the opportunity price book is different than the quoteand there are no line items in the opportunity, the save hook thatoccurs after rollup (e.g,OpportunityFunctions.saveHook_PostSummariesOnce) calls a function thatsynchronizes the quote during an update (e.g.,QuoteSynchronizer.syncOnUpdate( )) to synchronize the opportunity pricebook with the quote. The save hook that occurs after rollup (e.g.,OpportunityFunctions.saveHook_PostSummariesOnce) may be part of anentity save framework and allow object specific customizations to thesave flow. In step 510, if the quote price book is different than theopportunity and there are no line items in the opportunity, the savehook that occurs after rollup (e.g.,QuoteFunctions.saveHook_PostSummariesOnce) calls a function thatsynchronizes the opportunity during an update (e.g.,QuoteSynchronizer.syncOnUpdate( )) to synchronize the quote price bookwith the opportunity.

In step 512, if opportunity line items were inserted or updated and havefields differing from the synchronizing quote line item, the save hookthat occurs after rollup (e.g.OpportunityLineItemFunctions.saveHook_PostSummariesOnce) calls afunction that synchronizes the quote line items during an update (e.g.,LineItemSyncHelper.syncLineItemsOnUpdateInsert) to synchronize theopportunity line items with the quote line items.

In step 514, if opportunity line items were deleted, the delete hookthat occurs after rollup (e.g.,OpportunityLineItemFunctions.deleteHook_BeforeDeleteOnce) calls afunction that synchronizes quote line items (e.g.LineItemSyncHelper.syncLineItemsOnDelete) to delete the quote line itemsthat correspond to the opportunity line items that got deleted.

In step 516, if quote line items were inserted or if quote line itemswere updated resulting in one or more fields differing from thesynchronizing opportunity line items, the save hook that occurs afterrollup (e.g., QuoteLineItemFunctions.saveHook_PostSummariesOncerice)calls a function that synchronizes quote line items (e.g.,LineItemSyncHelper.syncLineItemsOnUpdatelnsert) to synchronize theinserted or updated quote line items.

In step 518, if quote line items were deleted, the delete hook thatoccurs after rollup (e.g.,QuoteLineItemFunctions.deleteHook_BeforeDeleteOnce) calls a functionthat synchronizes opportunity line items (e.g.,LineItemSyncHelper.syncLineItemsOnDelete) to delete the opportunity lineitems that correspond to the quote line items that got deleted.

In step 520, if quote line items were undeleted, the undelete hook thatoccurs after rollup (e.g.QuoteLineItemFunctions.undeleteHook_AfterUndeleteOnce) calls a functionthat synchronizes opportunity line items (e.g.,LineItemSyncHelper.syncQuoteLineItemsOnUndelete) to insert opportunityline items to match the quote line items that were undeleted.

In an embodiment, all of the methods may work in batch and expect toreceive a collection of objects from the current dmlOperationState. Anyerrors caught during a save operation may be mapped back to the originalsource object. In an embodiment, having access to the currentdmlOperationState may allow calling setThrowable on the object desiredto be “error” out. In an embodiment, it may be desirable to ensure thatthe object that was the source of the synchronization errored out, notthe target of the synchronization. For example, if an opportunity lineitem was updated (it is the source), an attempt is made to synchronizethe opportunity line item's corresponding quote line item (the target).If the attempt to synchronize the opportunity line item's correspondingquote line item fails, it may be desirable to call setThrowable on theopportunity line item. (See LineItemSyncHelper.handleSaveErrors).LineItemSyncHelper.handleSaveErrors may handle errors that occur duringthe synchronization process. In an embodiment,LineItemSyncHelper.handleSaveErrors maps errors to the correct objects.For example, if both quote 1 and quote 2 are being synchronized andquote 2 causes an error, the error would only be mapped to quote 2.

Synchronization performance is another consideration in thesynchronization process. In an embodiment, all synchronizationoperations (both for initial synchronization and ongoingsynchronization) may be compatible in batch so that API batch operationsmay perform and scale properly. In an embodiment, in order for API batchoperation to perform and scale properly, all places executingsynchronization logic may expect to receive a collection of objects fromthe current dml batch operation (usually from the dmlOperationState).When loading objects from the dml batch operation, assumptions may bemade about when objects may already be in the current transaction mapcache and use UddDb.getEntityObject( ) to retrieve objects. In anembodiment, if it is uncertain if an entity has already been loaded inthe current transaction, objects that are needed are bulk loadedupfront, then UddDb.getEntityObject( ) may be used to retrieve theobjects once it is determined the objects are in the transaction map.For example, when line items are updated, it may be necessary to verifyif the line items and the line item parents are synchronizing with eachother. The parent ids are needed and therefore may be bulk loadedupfront, then UddDb.getEntityObject( ) may be used to retrieve theparent ids at a later time when necessary to check their synchronizationstate.

Another synchronization consideration is error handling. Because alloperations may need to be compatible with batch, the operations may alsomap errors back to the right objects so that the entity save frameworkcan properly handle errors in the batch, including handling partialfailures.

Infinite Loop Detection

FIG. 6 illustrates a flowchart of an embodiment of a method 600 fordetecting infinite loop occurrences when synchronizing opportunity andquote data. A method 600 may include Opportunity Line parent update 602,Quote Line 1 True 604, Opportunity Line updating 606, Quote Lineupdating 608, Opportunity Line1 True 610, Quote Line1 Synchronization InProgress 612, RecursiveSynchronization Exception 614, and no error 616.In other embodiments, method 600 may not have all of the steps listedand/or may have other elements instead of, or in addition to, thoselisted.

Triggers and other working logic can cause infinite loops whensynchronized quotes or opportunities are involved. For example, triggerson both the quote and opportunity can cause the synchronization logic tocontinually synchronize back and forth. In an embodiment, to preventinfinite loops due to continual back and forth synchronization, whenobjects that support synchronization have already begun thesynchronization process, the object cannot be synchronized again duringthe same transaction.

In an embodiment, four objects that support synchronization,Opportunity, OppLineItem, Quote, and QuoteLineItem, may implement aSyncable interface. The Syncable interface may define theset/getIsSyncInProgress methods. These methods set and get a booleanrollbackable variable (e.g., isSyncInProgess) on the objects supportingsynchronization, indicating when an object is currently beingsynchronized. In an embodiment, a function may be called on an objectthat supports synchronization for indicating a synchronization is inprogress, (e.g., syncSyncUtil.setSyncStateToInProgress( ) method). In anembodiment, if the object is already in the process of synchronizing,calling the function for indicating a synchronization is in progress(e.g., SyncUtil.setSyncStateToInProgress( )) may result in aRecursiveSyncException being thrown. A RecursiveSyncException indicatesan error which may result in infinite loops if synchronization isallowed to execute.

A method 600 illustrates when an infinite loop may occur and aRecursiveSyncException 614 thrown. In step 602, if the parent of anOppLineItem is being updated, a Recursive SyncException 614 may bethrown. Step 602 illustrates the case of an object already insynchronization progress where the function for indicating asynchronization is in progress (e.g., SyncUti.setSyncStateToInProgress()) may be attempted to be called, resulting in a RecursiveSyncException614 being thrown. If the parent of an OppLineItem is not being updated,then no error 616 occurs.

In step QuoteLine1 True 604, if Boolean rollbackable variable (e.g.,QuoteLine1.isSyncInProgress) is set to TRUE and the quote line item isbeing updated with data from the parent opportunity line item, then aRecursiveSyncException 614 may be thrown. If the Boolean rollbackablevariable is FALSE, then no error 616 occurs.

In step 606, if an opportunity line item is updating itself due to apost trigger, a RecursiveSyncException 614 may be thrown. If anopportunity line item is not updating itself due to a post trigger, thenno error 616 occurs.

In step 608, if a quote line item is updating itself due to a posttrigger, a RecursiveSyncException 614 may be thrown. If a quote lineitem is not updating itself due to a post trigger, then no error 616occurs.

In step 610, if a Boolean rollbackable variable (e.g.OppLine1.isSyncInProgress) is set to TRUE and the Opportunity line itemis being updated with updated data from a quote line, then aRecursiveSyncException 616 may be thrown. If the Boolean rollbackablevariable (e.g., Oppline1.isSyncInProgress) is set to FALSE or ifOpportunity line item is not being updated with updated data from aquote line, then no error 616 occurs.

In step 612, if the Boolean rollbackable variable (e.g.,QuoteLine1.isSyncInProgress) is set to TRUE, a RecursiveSyncException614 may be thrown. If the Boolean rollbackable variables are set toFALSE, then no error 616 occurs.

System Overview

FIG. 7 illustrates a block diagram of an environment 710 wherein anon-demand database service might be used. Environment 710 may includeuser systems 712, network 714, system 716, processor system 717,application platform 718, network interface 720, tenant data storage722, system data storage 724, program code 726, and process space 728.In other embodiments, environment 710 may not have all of the componentslisted and/or may have other elements instead of, or in addition to,those listed above.

Environment 710 is an environment in which an on-demand database serviceexists. User system 712 may be any machine or system that is used by auser to access a database user system. For example, any of user systems712 can be a handheld computing device, a mobile phone, a laptopcomputer, a work station, and/or a network of computing devices. Asillustrated in FIG. 7 (and in more detail in FIG. 8) user systems 712might interact via a network 714 with an on-demand database service,which is system 716.

An on-demand database service, such as system 716, is a database systemthat is made available to outside users that do not need to necessarilybe concerned with building and/or maintaining the database system, butinstead may be available for their use when the users need the databasesystem (e.g., on the demand of the users). Some on-demand databaseservices may store information from one or more tenants stored intotables of a common database image to form a multi-tenant database system(MTS). Accordingly, “on-demand database service 716” and “system 716”will be used interchangeably herein. A database image may include one ormore database objects. A relational database management system (RDMS) orthe equivalent may execute storage and retrieval of information againstthe database object(s). Application platform 718 may be a framework thatallows the applications of system 716 to run, such as the hardwareand/or software, e.g., the operating system. In an embodiment, on-demanddatabase service 716 may include an application platform 718 thatenables creation, managing and executing one or more applicationsdeveloped by the provider of the on-demand database service, usersaccessing the on-demand database service via user systems 712, or thirdparty application developers accessing the on-demand database servicevia user systems 712.

The users of user systems 712 may differ in their respective capacities,and the capacity of a particular user system 712 might be entirelydetermined by permissions (permission levels) for the current user. Forexample, where a salesperson is using a particular user system 712 tointeract with system 716, that user system has the capacities allottedto that salesperson. However, while an administrator is using that usersystem to interact with system 716, that user system has the capacitiesallotted to that administrator. In systems with a hierarchical rolemodel, users at one permission level may have access to applications,data, and database information accessible by a lower permission leveluser, but may not have access to certain applications, databaseinformation, and data accessible by a user at a higher permission level.Thus, different users will have different capabilities with regard toaccessing and modifying application and database information, dependingon a user's security or permission level.

Network 714 is any network or combination of networks of devices thatcommunicate with one another. For example, network 714 can be any one orany combination of a LAN (local area network), WAN (wide area network),telephone network, wireless network, point-to-point network, starnetwork, token ring network, hub network, or other appropriateconfiguration. As the most common type of computer network in currentuse is a TCP/IP (Transfer Control Protocol and Internet Protocol)network, such as the global internetwork of networks often referred toas the “Internet” with a capital “I,” that network will be used in manyof the examples herein. However, it should be understood that thenetworks that the one or more implementations might use are not solimited, although TCP/IP is a frequently implemented protocol.

User systems 712 might communicate with system 716 using TCP/IP and, ata higher network level, use other common Internet protocols tocommunicate, such as HTTP, FTP, AFS, WAP, etc. In an example where HTTPis used, user system 712 might include an HTTP client commonly referredto as a “browser” for sending and receiving HTTP messages to and from anHTTP server at system 716. Such an HTTP server might be implemented asthe sole network interface between system 716 and network 714, but othertechniques might be used as well or instead. In some implementations,the interface between system 716 and network 714 includes load sharingfunctionality, such as round-robin HTTP request distributors to balanceloads and distribute incoming HTTP requests evenly over a plurality ofservers. At least as for the users that are accessing that server, eachof the plurality of servers has access to the MTS' data; however, otheralternative configurations may be used instead.

In one embodiment, system 716, shown in FIG. 7, implements a web-basedcustomer relationship management (CRM) system. For example, in oneembodiment, system 716 includes application servers configured toimplement and execute CRM software applications as well as providerelated data, code, forms, webpages and other information to and fromuser systems 712 and to store to, and retrieve from, a database systemrelated data, objects, and Webpage content. With a multi-tenant system,data for multiple tenants may be stored in the same physical databaseobject, however, tenant data typically is arranged so that data of onetenant is kept logically separate from that of other tenants so that onetenant does not have access to another tenant's data, unless such datais expressly shared. In certain embodiments, system 716 implementsapplications other than, or in addition to, a CRM application. Forexample, system 716 may provide tenant access to multiple hosted(standard and custom) applications, including a CRM application. User(or third party developer) applications, which may or may not includeCRM, may be supported by the application platform 718, which managescreation, storage of the applications into one or more database objectsand executing of the applications in a virtual machine in the processspace of the system 716.

One arrangement for elements of system 716 is shown in FIG. 7, includinga network interface 720, application platform 718, tenant data storage722 for tenant data 723, system data storage 724 for system data 725accessible to system 716 and possibly multiple tenants, program code 726for implementing various functions of system 716, and a process space728 for executing MTS system processes and tenant-specific processes,such as running applications as part of an application hosting service.Additional processes that may execute on system 716 include databaseindexing processes.

Several elements in the system shown in FIG. 7 include conventional,well-known elements that are explained only briefly here. For example,each user system 712 could include a desktop personal computer,workstation, laptop, PDA, cell phone, or any wireless access protocol(WAP) enabled device or any other computing device capable ofinterfacing directly or indirectly to the Internet or other networkconnection. User system 712 typically runs an HTTP client, e.g., abrowsing program, such as Microsoft's Internet Explorer browser,Netscape's Navigator browser, Opera's browser, or a WAP-enabled browserin the case of a cell phone, PDA or other wireless device, or the like,allowing a user (e.g., subscriber of the multi-tenant database system)of user system 712 to access, process and view information, pages andapplications available to it from system 716 over network 714. Each usersystem 712 also typically includes one or more user interface devices,such as a keyboard, a mouse, trackball, touch pad, touch screen, pen orthe like, for interacting with a graphical user interface (GUI) providedby the browser on a display (e.g., a monitor screen, LCD display, etc.)in conjunction with pages, forms, applications and other informationprovided by system 716 or other systems or servers. For example, theuser interface device can be used to access data and applications hostedby system 716, and to perform searches on stored data, and otherwiseallow a user to interact with various GUI pages that may be presented toa user. As discussed above, embodiments are suitable for use with theInternet, which refers to a specific global internetwork of networks.However, it should be understood that other networks can be used insteadof the Internet, such as an intranet, an extranet, a virtual privatenetwork (VPN), a non-TCP/IP based network, any LAN or WAN or the like.

According to one embodiment, each user system 712 and all of itscomponents are operator configurable using applications, such as abrowser, including computer code run using a central processing unitsuch as an Intel Pentium® processor or the like. Similarly, system 716(and additional instances of an MTS, where more than one is present) andall of their components might be operator configurable usingapplication(s) including computer code to run using a central processingunit such as processor system 717, which may include an Intel Pentium®processor or the like, and/or multiple processor units. A computerprogram product embodiment includes a machine-readable storage medium(media) having instructions stored thereon/in which can be used toprogram a computer to perform any of the processes of the embodimentsdescribed herein. Computer code for operating and configuring system 716to intercommunicate and to process webpages, applications and other dataand media content as described herein are preferably downloaded andstored on a hard disk, but the entire program code, or portions thereof,may also be stored in any other volatile or non-volatile memory mediumor device as is well known, such as a ROM or RAM, or provided on anymedia capable of storing program code, such as any type of rotatingmedia including floppy disks, optical discs, digital versatile disk(DVD), compact disk (CD), microdrive, and magneto-optical disks, andmagnetic or optical cards, nanosystems (including molecular memory ICs),or any type of media or device suitable for storing instructions and/ordata. Additionally, the entire program code, or portions thereof, may betransmitted and downloaded from a software source over a transmissionmedium, e.g., over the Internet, or from another server, as is wellknown, or transmitted over any other conventional network connection asis well known (e.g., extranet, VPN, LAN, etc.) using any communicationmedium and protocols (e.g., TCP/IP, HTTP, HTTPS, Ethernet, etc.) as arewell known. It will also be appreciated that computer code forimplementing embodiments can be implemented in any programming languagethat can be executed on a client system and/or server or server systemsuch as, for example, C, C++, HTML, any other markup language, Java™,JavaScript, ActiveX, any other scripting language, such as VBScript, andmany other programming languages as are well known may be used. (Java™is a trademark of Sun Microsystems, Inc.).

According to one embodiment, each system 716 is configured to providewebpages, forms, applications, data and media content to user (client)systems 712 to support the access by user systems 712 as tenants ofsystem 716. As such, system 716 provides security mechanisms to keepeach tenant's data separate unless the data is shared. If more than oneMTS is used, they may be located in close proximity to one another(e.g., in a server farm located in a single building or campus), or theymay be distributed at locations remote from one another (e.g., one ormore servers located in city A and one or more servers located in cityB). As used herein, each MTS could include one or more logically and/orphysically connected servers distributed locally or across one or moregeographic locations. Additionally, the term “server” is meant toinclude a computer system, including processing hardware and processspace(s), and an associated storage system and database application(e.g., OODBMS or RDBMS) as is well known in the art. It should also beunderstood that “server system” and “server” are often usedinterchangeably herein. Similarly, the database object described hereincan be implemented as single databases, a distributed database, acollection of distributed databases, a database with redundant online oroffline backups or other redundancies, etc., and might include adistributed database or storage network and associated processingintelligence.

FIG. 8 also illustrates environment 710. However, in FIG. 8 elements ofsystem 716 and various interconnections in an embodiment are furtherillustrated. FIG. 8 shows that user system 712 may include processorsystem 712A, memory system 712B, input system 712C, and output system712D. FIG. 8 shows network 714 and system 716. FIG. 8 also shows thatsystem 716 may include tenant data storage 722, tenant data 723, systemdata storage 724, system data 725, User Interface (UI) 830, ApplicationProgram Interface (API) 832, PL/SOQL 834, save routines 836, applicationsetup mechanism 838, applications servers 800 ₁-800 _(N), system processspace 802, tenant process spaces 804, tenant management process space810, tenant storage space 812, tenant data 814, and application metadata816. In other embodiments, environment 710 may not have the sameelements as those listed above and/or may have other elements insteadof, or in addition to, those listed above.

User system 712, network 714, system 716, tenant data storage 722, andsystem data storage 724 were discussed above in FIG. 7. Regarding usersystem 712, processor system 712A may be any combination of one or moreprocessors. Memory system 712B may be any combination of one or morememory devices, short term, and/or long term memory. Input system 712Cmay be any combination of input devices, such as one or more keyboards,mice, trackballs, scanners, cameras, and/or interfaces to networks.Output system 712D may be any combination of output devices, such as oneor more monitors, printers, and/or interfaces to networks. As shown byFIG. 8, system 716 may include a network interface 720 (of FIG. 7)implemented as a set of HTTP application servers 800, an applicationplatform 718, tenant data storage 722, and system data storage 724. Alsoshown is system process space 802, including individual tenant processspaces 804 and a tenant management process space 810. Each applicationserver 800 may be configured to tenant data storage 722 and the tenantdata 723 therein, and system data storage 724 and the system data 725therein to serve requests of user systems 712. The tenant data 723 mightbe divided into individual tenant storage spaces 812, which can beeither a physical arrangement and/or a logical arrangement of data.Within each tenant storage space 812, tenant data 814 and applicationmetadata 816 might be similarly allocated for each user. For example, acopy of a user's most recently used (MRU) items might be stored totenant data 814. Similarly, a copy of MRU items for an entireorganization that is a tenant might be stored to tenant storage space812. A UI 830 provides a user interface and an API 832 provides anapplication programmer interface to system 716 resident processes tousers and/or developers at user systems 712. The tenant data and thesystem data may be stored in various databases, such as one or moreOracle' databases.

Application platform 718 includes an application setup mechanism 838that supports application developers' creation and management ofapplications, which may be saved as metadata into tenant data storage722 by save routines 836 for execution by subscribers as one or moretenant process spaces 804 managed by tenant management process 810 forexample. Invocations to such applications may be coded using PL/SOQL 834that provides a programming language style interface extension to API832. A detailed description of some PL/SOQL language embodiments isdiscussed in commonly owned co-pending U.S. Provisional PatentApplication 60/828,192 entitled, PROGRAMMING LANGUAGE METHOD AND SYSTEMFOR EXTENDING APIS TO EXECUTE IN CONJUNCTION WITH DATABASE APIS, byCraig Weissman, filed Oct. 4, 2006, which is incorporated in itsentirety herein for all purposes. Invocations to applications may bedetected by one or more system processes, which manage retrievingapplication metadata 816 for the subscriber making the invocation andexecuting the metadata as an application in a virtual machine.

Each application server 800 may be communicably coupled to databasesystems, e.g., having access to system data 725 and tenant data 723, viaa different network connection. For example, one application server 800imight be coupled via the network 714 (e.g., the Internet), anotherapplication server 800 _(N-1) might be coupled via a direct networklink, and another application server 800 _(N) might be coupled by yet adifferent network connection. Transfer Control Protocol and InternetProtocol (TCP/IP) are typical protocols for communicating betweenapplication servers 800 and the database system. However, it will beapparent to one skilled in the art that other transport protocols may beused to optimize the system depending on the network interconnect used.

In certain embodiments, each application server 800 is configured tohandle requests for any user associated with any organization that is atenant. Because it is desirable to be able to add and remove applicationservers from the server pool at any time for any reason, there ispreferably no server affinity for a user and/or organization to aspecific application server 800. In one embodiment, therefore, aninterface system implementing a load balancing function (e.g., an F5Big-IP load balancer) is communicably coupled between the applicationservers 800 and the user systems 712 to distribute requests to theapplication servers 800. In one embodiment, the load balancer uses aleast connections algorithm to route user requests to the applicationservers 800. Other examples of load balancing algorithms, such as roundrobin and observed response time, also can be used. For example, incertain embodiments, three consecutive requests from the same user couldhit three different application servers 800, and three requests fromdifferent users could hit the same application server 800. In thismanner, system 716 is multi-tenant, wherein system 716 handles storageof, and access to, different objects, data and applications acrossdisparate users and organizations.

As an example of storage, one tenant might be a company that employs asales force where each salesperson uses system 716 to manage their salesprocess. Thus, a user might maintain contact data, leads data, customerfollow-up data, performance data, goals and progress data, etc., allapplicable to that user's personal sales process (e.g., in tenant datastorage 722). In an example of a MTS arrangement, since all of the dataand the applications to access, view, modify, report, transmit,calculate, etc., can be maintained and accessed by a user system havingnothing more than network access, the user can manage his or her salesefforts and cycles from any of many different user systems. For example,if a salesperson is visiting a customer and the customer has Internetaccess in their lobby, the salesperson can obtain critical updates as tothat customer while waiting for the customer to arrive in the lobby.

While each user's data might be separate from other users' dataregardless of the employers of each user, some data might beorganization-wide data shared or accessible by a plurality of users orall of the users for a given organization that is a tenant. Thus, theremight be some data structures managed by system 716 that are allocatedat the tenant level while other data structures might be managed at theuser level. Because an MTS might support multiple tenants includingpossible competitors, the MTS should have security protocols that keepdata, applications, and application use separate. Also, because manytenants may opt for access to an MTS rather than maintain their ownsystem, redundancy, up-time, and backup are additional functions thatmay be implemented in the MTS. In addition to user-specific data andtenant specific data, system 716 might also maintain system level datausable by multiple tenants or other data. Such system level data mightinclude industry reports, news, postings, and the like that are sharableamong tenants.

In certain embodiments, user systems 712 (which may be client systems)communicate with application servers 800 to request and updatesystem-level and tenant-level data from system 716 that may requiresending one or more queries to tenant data storage 722 and/or systemdata storage 724. System 716 (e.g., an application server 800 in system716) automatically generates one or more SQL statements (e.g., one ormore SQL queries) that are designed to access the desired information.System data storage 724 may generate query plans to access the requesteddata from the database.

Each database can generally be viewed as a collection of objects, suchas a set of logical tables, containing data fitted into predefinedcategories. A “table” is one representation of a data object, and may beused herein to simplify the conceptual description of objects and customobjects. It should be understood that “table” and “object” may be usedinterchangeably herein. Each table generally contains one or more datacategories logically arranged as columns or fields in a viewable schema.Each row or record of a table contains an instance of data for eachcategory defined by the fields. For example, a CRM database may includea table that describes a customer with fields for basic contactinformation such as name, address, phone number, fax number, etc.Another table might describe a purchase order, including fields forinformation such as customer, product, sale price, date, etc. In somemulti-tenant database systems, standard entity tables might be providedfor use by all tenants. For CRM database applications, such standardentities might include tables for Account, Contact, Lead, andOpportunity data, each containing pre-defined fields. It should beunderstood that the word “entity” may also be used interchangeablyherein with “object” and “table”.

In some multi-tenant database systems, tenants may be allowed to createand store custom objects, or they may be allowed to customize standardentities or objects, for example by creating custom fields for standardobjects, including custom index fields. U.S. patent application Ser. No.10/817,161, filed Apr. 2, 2004, entitled “Custom Entities and Fields ina Multi-Tenant Database System”, and which is hereby incorporated hereinby reference, teaches systems and methods for creating custom objects aswell as customizing standard objects in a multi-tenant database system.In certain embodiments, for example, all custom entity data rows arestored in a single multi-tenant physical table, which may containmultiple logical tables per organization. It is transparent to customersthat their multiple “tables” are in fact stored in one large table orthat their data may be stored in the same table as the data of othercustomers.

Method for Using the Environment (FIGS. 7 and 8)

FIG. 9 shows a flowchart of an example of a method 900 of usingenvironment 710. In step 910, user system 712 (FIGS. 7 and 8)establishes an account. In step 912, one more tenant process space 804(FIG. 8) are initiated on behalf of user system 712, which may alsoinvolve setting aside space in tenant space 812 (FIG. 8) and tenant data814 (FIG. 8) for user system 712. Step 912 may also involve modifyingapplication metadata to accommodate user system 712. In step 914, usersystem 712 uploads data. In step 916, one or more data objects are addedto tenant data 814 where the data uploaded is stored. In step 918,methods for synchronizing data in a multi-tenant database environmentmay be implemented. In another embodiment, although depicted as distinctsteps in FIG. 9, steps 902-918 may not be distinct steps. In otherembodiments, method 900 may not have all of the above steps and/or mayhave other steps in addition to, or instead of, those listed above. Thesteps of method 900 may be performed in another order. Subsets of thesteps listed above as part of method 900 may be used to form their ownmethod.

Method for Creating the Environment (FIGS. 7 and 8)

FIG. 10 is a method of making environment 710, in step 1002, user system712 (FIGS. 7 and 8) is assembled, which may include communicativelycoupling one or more processors, one or more memory devices, one or moreinput devices (e.g., one or more mice, keyboards, and/or scanners), oneor more output devices (e.g., one more printers, one or more interfacesto networks, and/or one or more monitors) to one another.

In step 1004, system 716 (FIGS. 7 and 8) is assembled, which may includecommunicatively coupling one or more processors, one or more memorydevices, one or more input devices (e.g., one or more mice, keyboards,and/or scanners), one or more output devices (e.g., one more printers,one or more interfaces to networks, and/or one or more monitors) to oneanother. Additionally assembling system 716 may include installingapplication platform 718, network interface 720, tenant data storage722, system data storage 724, system data 725, program code 726, processspace 728, UI 830, API 832, PL/SOQL 834, save routine 836, applicationsetup mechanism 838, applications servers 800 ₁-800 _(N), system processspace 802, tenant process spaces 804, tenant management process space810, tenant space 812, tenant data 814, and application metadata 816(FIG. 8).

In step 1006, user system 712 is communicatively coupled to network 714.In step 1008, system 716 is communicatively coupled to network 714allowing user system 712 and system 716 to communicate with one another(FIG. 8). In step 1010, one or more instructions may be installed insystem 716 (e.g., the instructions may be installed on one or moremachine readable media, such as computer readable media, therein) and/orsystem 716 is otherwise configured for performing the steps of methodsfor synchronizing data in a multi-tenant database environment. Forexample, as part of step 1010, one or more instructions may be enteredinto the memory of system 716 for synchronizing data in a multi-tenantdatabase environment.

In another embodiment, although depicted as distinct steps in FIG. 10,steps 1002-1010 may not be distinct steps. In other embodiments, method1000 may not have all of the above steps and/or may have other steps inaddition to, or instead of, those listed above. The steps of method 1000may be performed in another order. Subsets of the steps listed above aspart of method 1000 may be used to form their own method.

Extensions and Alternatives

Each embodiment disclosed herein may be used or otherwise combined withany of the other embodiments disclosed. Any element of any embodimentmay be used in any embodiment.

In an embodiment, the initial synchronization logic may be within thesave lifecycle of Opportunity object (in saveHook_BeforeWorkflowOnce).In another embodiment, it may be beneficial to decouple the initialsynchronization logic from the save process and move the initialsynchronization logic into its own function similar to an API Method.Making the initial synchronization logic an API Method may also simplifythe API interface.

In an embodiment, QuoteSynchronizerImpl and LineItemHelperImpl may bothbe implemented as singletons and therefore may be stateless, e.g. noneof the methods rely on the state of class variables. There may beinstances where making QuoteSynchronizerImpl and LineItemHelperImplstateful would allow for better caching of objects that have been bulkloaded and when the objects are known to have not been changed. In anembodiment, the caching of objects in the transaction object map may betasked to the UddDb and thus call UddDb.getEntityObject directly withthe assumption that the object may already be in the transaction objectmap and therefore would not cause an additional database query, i.e. seeLineItemHelperImpl.checkLineItemsAreSyncing. In an embodiment, it may bemore efficient to implement caching without the use of the UddDbimplementation.

While the invention has been described by way of example and in terms ofthe specific embodiments, it is to be understood that the invention isnot limited to the disclosed embodiments. To the contrary, it isintended to cover various modifications and similar arrangements aswould be apparent to those skilled in the art. Therefore, the scope ofthe appended claims should be accorded the broadest interpretation so asto encompass all such modifications and similar arrangements.

1. A method for synchronizing data in an on-demand services environment,the method comprising: receiving at a host system, a request from a usersystem to initiate a workflow that accesses at least one of a firstobject and a second object, the host system having a processor systemincluding at least one processor and a memory system; initiating theworkflow with the host system to synchronize the first object with thesecond object by at least determining, by the processor system, ifeither the first object and the second object includes line items to besynchronized, if the first object and the second object have line itemsto be synchronized, performing a rollup for one or more line items, ifthe first object and the second object do not have line items to besynchronized, if a value stored in a first element of the first objectchanged, determining, by the processor system, whether a second objectis being synchronized to the first object, and if the second object isbeing synchronized to the first object, updating, by the host system,the second object, such that a second element that corresponds to thefirst element, but is in the second object, has a value that agrees withthe value stored in the first element; determining, by the host system,whether an error condition occurs; and if the error condition is notdetected, saving the updating in the memory system of the host system.2. The method of claim 1 wherein the synchronizing of the first objectand second object includes at least deleting, updating, and insertingelements of the first object to agree with the second object, thedeleting of elements includes at least removing data from fields fromthe first object to match a corresponding empty field from the secondobject, the inserting of elements includes at least adding data tofields of the first object to match a corresponding field containingdata from the second object.
 3. The method of claim 1 wherein the firstobject is an opportunity, the opportunity including at least dataassociated with selling products to a customer, the opportunity beingstored, in a portion of the database dedicated to the tenant.
 4. Themethod of claim 1 wherein the second object is a quote, the quoteincluding at least sales information given to a customer, the quotebeing stored in a portion of the database dedicated to the tenant. 5.The method of claim 1 wherein the first object is an opportunity and thesecond object is a quote, each having at least six elements, theelements including at least a quantity, a price, a discount, a servicedate, a revenue schedule, and a quantity schedule.
 6. The method ofclaim 1 further comprising sending a user interface having asynchronization button to the user system, wherein receiving the requestincludes at least receiving an indication that the user selected thesynchronize button.
 7. The method of claim 1, wherein the request ismade by designating, via an application programming interface, the firstobject and second object for synchronization.
 8. The method of claim 1wherein the error condition is an attempt to perform a secondsynchronization within a single transaction.
 9. A non-transitorycomputer-readable medium having stored thereon instructions forsynchronizing data in a multi-tenant database environment that, whenexecuted, cause one or more processors to: receive at a host system, arequest from a user system to initiate a workflow that accesses at leastone of a first object and a second object, the host system having aprocessor system including at least one processor and a memory system;initiate the workflow with the host system to synchronize the firstobject with the second object by at least determining, by the processorsystem, if either the first object and the second object includes lineitems to be synchronized, if the first object and the second object haveline items to be synchronized, performing a rollup for one or more lineitems, if the first object and the second object do not have line itemsto be synchronized, if a value stored in a first element of the firstobject changed, determining, by the processor system, whether a secondobject is being synchronized to the first object, and if the secondobject is being synchronized to the first object, updating, by the hostsystem, the second object, such that a second element that correspondsto the first element, but is in the second object, has a value thatagrees with the value stored in the first element; determining, by thehost system, whether an error condition occurs; and if the errorcondition is not detected, saving the updating in the memory system ofthe host system.
 10. The non-transitory computer-readable medium ofclaim 9 wherein the synchronizing of the first object and second objectincludes at least deleting, updating, and inserting elements of thefirst object to agree with the second object, the deleting of elementsincludes at least removing data from fields from the first object tomatch a corresponding empty field from the second object, the insertingof elements includes at least adding data to fields of the first objectto match a corresponding field containing data from the second object.11. The non-transitory computer-readable medium of claim 9 wherein thefirst object is an opportunity, the opportunity including at least dataassociated with selling products to a customer, the opportunity beingstored, in a portion of the database dedicated to the tenant.
 12. Thenon-transitory computer-readable medium of claim 9 wherein the secondobject is a quote, the quote including at least sales information givento a customer, the quote being stored in a portion of the databasededicated to the tenant.
 13. The non-transitory computer-readable mediumof claim 9 wherein the first object is an opportunity and the secondobject is a quote, each having at least six elements, the elementsincluding at least a quantity, a price, a discount, a service date, arevenue schedule, and a quantity schedule.
 14. The non-transitorycomputer-readable medium of claim 9 further comprising sending a userinterface having a synchronization button to the user system, whereinreceiving the request includes at least receiving an indication that theuser selected the synchronize button.
 15. The non-transitorycomputer-readable medium of claim 9, wherein the request is made bydesignating, via an application programming interface, the first objectand second object for synchronization.
 16. The non-transitorycomputer-readable medium of claim 9 wherein the error condition is anattempt to perform a second synchronization within a single transaction.17. A system comprising: one or more computing systems, each having atleast one processor coupled with memory, the one or more computingsystems to receive a request from a user computing system to initiate aworkflow that accesses at least one of a first object and a secondobject, to initiate the workflow to synchronize the first object withthe second object by at least determining, by the processor system, ifeither the first object and the second object includes line items to besynchronized, if the first object and the second object have line itemsto be synchronized, performing a rollup for one or more line items, ifthe first object and the second object do not have line items to besynchronized, if a value stored in a first element of the first objectchanged, determining, by the processor system, whether a second objectis being synchronized to the first object, and if the second object isbeing synchronized to the first object, updating, by the host system,the second object, such that a second element that corresponds to thefirst element, but is in the second object, has a value that agrees withthe value stored in the first element; the one or more computing systemsfurther to determine whether an error condition occurs, and if the errorcondition is not detected, save the updating in the memory.
 18. Thesystem of claim 17 wherein the synchronizing of the first object andsecond object includes at least deleting, updating, and insertingelements of the first object to agree with the second object, thedeleting of elements includes at least removing data from fields fromthe first object to match a corresponding empty field from the secondobject, the inserting of elements includes at least adding data tofields of the first object to match a corresponding field containingdata from the second object.
 19. The system of claim 17 wherein thefirst object is an opportunity, the opportunity including at least dataassociated with selling products to a customer, the opportunity beingstored, in a portion of the database dedicated to the tenant.
 20. Thesystem of claim 17 wherein the second object is a quote, the quoteincluding at least sales information given to a customer, the quotebeing stored in a portion of the database dedicated to the tenant.